#@layout()

#define script()
<script>

    function deliver(id) {
        openlayer('发货','#(CPATH)/admin/order/deliver/'+id);
    }

    function openlayer(title,url) {
        layer.open({
            type: 2,
            title: title,
            anim: 2,
            shadeClose: true,
            shade: 0.3,
            area: ['70%', '90%'],
            content: url,
            end: function () {
                if (layer.data.needRefresh){
                    location.reload();
                }
            }
        });
    }

</script>
#end

#define css()
<style>
    .card-title{
        text-align: center;
        float: none;
    }
    .card-title a{
        color:#007bff;
        font-weight: bold;
    }
</style>
#end




#define content()
    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                订单列表
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 财务 / 订单列表</small>
                            </h1>
                        </div>
                    </div>

                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>

    <section class="content-header text-tap">
        <div class="row">

            <div class="col-lg-3 col-xs-6">
                <!-- small card -->
                <div class="small-box bg-red">
                    <div class="inner">
                        <h3>#(todayOrderCount ?? 0)</h3>

                        <p>今日订单</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-pie-graph"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->

            <div class="col-lg-3 col-xs-6">
                <!-- small card -->
                <div class="small-box bg-info">
                    <div class="inner">
                        <h3>#(monthOrderCount ?? 0)</h3>

                        <p>本月订单</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-bag"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small card -->
                <div class="small-box bg-green">
                    <div class="inner">
                        <h3>#(mouthPaymentAmount ?? 0)</h3>

                        <p>本月销售</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-stats-bars"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small card -->
                <div class="small-box bg-yellow">
                    <div class="inner">
                        <h3>#(mountOrderUserCount ?? 0)</h3>

                        <p>本月购买用户</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-person"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->

        </div>

    </section>

    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <div class="card-header with-border">
                        <form class=" admin-search-panel" action="" method="get">
                            <div class="row">
                                <div class="form-group col-lg-2">
                                        <input type="text" placeholder="商品" class="form-control" name="productTitle" value="#(productTitle)">
                                </div>
                                <div class="form-group col-lg-2">
                                        <input class="form-control" placeholder="订单号" name="ns" value="#(ns)">
                                </div>
                                <div class="form-group col-lg-2">
                                    <button type="submit" class="btn btn-primary ">查询</button>
                                    <button type="reset" class="btn btn-default">重置</button>
                                </div>
                            </div>
                            <!-- /.card-body -->
                        </form>

                    </div>
                    <!-- /.card-header -->
                    <div class="card-body p-0">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="text-align: center">商品</th>
                                <th style="text-align: center">数量</th>
                                <th style="text-align: center">单价</th>
                                <th style="text-align: center">总价</th>
                                <th style="text-align: center">操作</th>
                            </tr>


                            #for(order : page.list ??)
                            <tr>
                                <td colspan="5" bgcolor="#fff">
                                    <div class="card card-outline card-dashboard" style="margin-bottom: 0px">
                                        <div class="card-header with-border row">
                                            <div class="col-lg-10">
                                                订单号：#(order.ns ??)
                                                #if(order.isFinished())
                                                （<span style="">#(order.tradeStatusStr ??)</span>）
                                                #elseif(order.isPaySuccess() )
                                                （<span style="color:green">#(order.tradeStatusStr ??)</span>）
                                                #elseif(order.isClosed())
                                                (<span>#(order.tradeStatusStr ??)</span>）
                                                #else
                                                （<span style="color:red">#(order.tradeStatusStr ??)</span>）
                                                #end

                                                总金额：<span style="padding-right: 20px">#(order.orderRealAmount ??)</span>

                                                #if(order.isPaySuccess() || order.isClosed())
                                                支付状态：<span style="padding-right: 20px">#(order.payStatusStr ??)</span>
                                                #else
                                                支付状态：<span style="color:red;padding-right: 20px">#(order.payStatusStr ??)</span>
                                                #end

                                                #if(order.isDeliveried() || order.isClosed())
                                                物流状态：<span style="padding-right: 20px">#(order.deliveryStatusStr ??)</span>
                                                #else
                                                物流状态：<span style="color:red;padding-right: 20px">#(order.deliveryStatusStr ??)</span>
                                                #end

                                                发票状态：<span style="padding-right: 20px">#(order.invoiceStatusStr ??)</span>
                                            </div>
                                            <div class="col-lg-2" style="text-align: right">
                                                <h3 class="card-title">
                                                    #if(!order.isUnpay() && !order.isClosed() && !order.isDeliveried())
                                                    <a href="javascript:;" onclick="deliver('#(order.id)')">发货</a>
                                                    #end
                                                    <a href="#(CPATH)/admin/order/detail/#(order.id)">详情</a>
                                                </h3>
                                            </div>
                                        </div>
                                        <!-- /.card-header -->
                                        <div class="card-body p-0">
                                            <table class="table table-striped">
                                                <tbody>
                                                #for(item : order.items)
                                                <tr>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_title ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_count ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_price ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_price * item.product_count ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        --
                                                    </td>
                                                </tr>
                                                #end
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            #else
                            <tr class="nodata"><td colspan="999">暂无数据</td> </tr>
                            #end

                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="offset-6 col-sm-6">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </div>
                <!-- /.card -->
            </div>
    </section>

#end
